package ProvaView;

import DisciplinaTopico.Topico;
import DisciplinaTopico.TopicoDAOException;
import DisciplinaTopicoView.TopicoDAO;
import Media.MediaController;
import Prova.Prova;
import java.util.ArrayList;
import java.util.List;

public class TelaParametrosProva extends javax.swing.JFrame
{
    private List<Topico> topicos = new ArrayList<Topico>();
    private static TopicoDAO topicoDAO;

    public List<Topico> getTopicos()
    {
        return topicos;
    }

    public void setTopicos(List<Topico> topicos)
    {
        this.topicos = topicos;
    }

    public TelaParametrosProva(TopicoDAO DAOTopico)
    {
        try
        {
            initComponents();
            topicoDAO = DAOTopico;
            topicos = topicoDAO.getTopicos();
            populaListaTopicos();
        } 
        catch (TopicoDAOException topicoEx)
        {
            MediaController.showErrorMessage("Não foi possivel realizar a conexão com o banco de dados. Exceção: " + topicoEx.getMessage(), "Erro na conexão");
            this.setVisible(false);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbQuestoesDisc = new javax.swing.JLabel();
        lbNumQuestoesDisc = new javax.swing.JLabel();
        lbNumQuestoesFaceisDisc = new javax.swing.JLabel();
        lbNumQuestoesMediasDisc = new javax.swing.JLabel();
        lbNumQuestoesDificiesDisc = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        lbQuestoesMultEsc = new javax.swing.JLabel();
        lbNumQuestoesMultEsc = new javax.swing.JLabel();
        lbNumQuestoesFaceisMultEsc = new javax.swing.JLabel();
        lbNumQuestoesMediasMultEsc = new javax.swing.JLabel();
        lbNumQuestoesDificiesMultEsc = new javax.swing.JLabel();
        lbTopicos = new javax.swing.JLabel();
        btnGerarProva = new javax.swing.JButton();
        tbxNumQuestoesDisc = new javax.swing.JTextField();
        tbxNumQuestoesFaceisDisc = new javax.swing.JTextField();
        tbxNumQuestoesMediasDisc = new javax.swing.JTextField();
        tbxNumQuestoesDificiesDisc = new javax.swing.JTextField();
        tbxNumQuestoesMultEsc = new javax.swing.JTextField();
        tbxNumQuestoesFaceisMultEsc = new javax.swing.JTextField();
        tbxNumQuestoesMediasMultEsc = new javax.swing.JTextField();
        tbxNumQuestoesDificiesMultEsc = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        lbxTopicos = new javax.swing.JList();
        lbComentario = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        lbQuestoesDisc.setText("Questões Discursivas");

        lbNumQuestoesDisc.setText("Número de Questões");

        lbNumQuestoesFaceisDisc.setText("Quantidade questões fáceis");

        lbNumQuestoesMediasDisc.setText("Quantidade questões médias");

        lbNumQuestoesDificiesDisc.setText("Quantidade questões difícies");

        lbQuestoesMultEsc.setText("Questões Múltiplas-Escolha");

        lbNumQuestoesMultEsc.setText("Número de Questões");

        lbNumQuestoesFaceisMultEsc.setText("Quantidade questões fáceis");

        lbNumQuestoesMediasMultEsc.setText("Quantidade questões médias");

        lbNumQuestoesDificiesMultEsc.setText("Quantidade questões difícies");

        lbTopicos.setText("Tópicos");

        btnGerarProva.setText("Gerar Prova");
        btnGerarProva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGerarProvaActionPerformed(evt);
            }
        });

        tbxNumQuestoesDisc.setEnabled(false);

        tbxNumQuestoesFaceisDisc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbxNumQuestoesFaceisDiscFocusLost(evt);
            }
        });
        tbxNumQuestoesFaceisDisc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxNumQuestoesFaceisDiscKeyTyped(evt);
            }
        });

        tbxNumQuestoesMediasDisc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbxNumQuestoesMediasDiscFocusLost(evt);
            }
        });
        tbxNumQuestoesMediasDisc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxNumQuestoesMediasDiscKeyTyped(evt);
            }
        });

        tbxNumQuestoesDificiesDisc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbxNumQuestoesDificiesDiscFocusLost(evt);
            }
        });
        tbxNumQuestoesDificiesDisc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxNumQuestoesDificiesDiscKeyTyped(evt);
            }
        });

        tbxNumQuestoesMultEsc.setEnabled(false);

        tbxNumQuestoesFaceisMultEsc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbxNumQuestoesFaceisMultEscFocusLost(evt);
            }
        });
        tbxNumQuestoesFaceisMultEsc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxNumQuestoesFaceisMultEscKeyTyped(evt);
            }
        });

        tbxNumQuestoesMediasMultEsc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbxNumQuestoesMediasMultEscFocusLost(evt);
            }
        });
        tbxNumQuestoesMediasMultEsc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxNumQuestoesMediasMultEscKeyTyped(evt);
            }
        });

        tbxNumQuestoesDificiesMultEsc.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tbxNumQuestoesDificiesMultEscFocusLost(evt);
            }
        });
        tbxNumQuestoesDificiesMultEsc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxNumQuestoesDificiesMultEscKeyTyped(evt);
            }
        });

        lbxTopicos.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        lbxTopicos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbxTopicosMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(lbxTopicos);

        lbComentario.setText("* Para escolher mais de um tópico pressione o CTRL enquanto clicar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbQuestoesDisc)
                .addContainerGap(328, Short.MAX_VALUE))
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbQuestoesMultEsc)
                .addContainerGap(300, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbNumQuestoesMultEsc)
                            .addComponent(lbNumQuestoesMediasMultEsc)
                            .addComponent(lbNumQuestoesFaceisMultEsc))
                        .addGap(70, 70, 70))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbNumQuestoesDificiesMultEsc)
                        .addGap(71, 71, 71)))
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tbxNumQuestoesDificiesMultEsc, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
                    .addComponent(tbxNumQuestoesFaceisMultEsc, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
                    .addComponent(tbxNumQuestoesMediasMultEsc, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
                    .addComponent(tbxNumQuestoesMultEsc, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(81, 81, 81))
            .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbNumQuestoesDificiesDisc)
                    .addComponent(lbNumQuestoesMediasDisc)
                    .addComponent(lbNumQuestoesFaceisDisc)
                    .addComponent(lbNumQuestoesDisc))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 87, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(tbxNumQuestoesMediasDisc)
                    .addComponent(tbxNumQuestoesFaceisDisc)
                    .addComponent(tbxNumQuestoesDisc, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
                    .addComponent(tbxNumQuestoesDificiesDisc, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(81, 81, 81))
            .addGroup(layout.createSequentialGroup()
                .addGap(106, 106, 106)
                .addComponent(btnGerarProva, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(115, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbTopicos)
                .addContainerGap(394, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(lbComentario)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                        .addGap(40, 40, 40))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(lbQuestoesDisc)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNumQuestoesDisc)
                    .addComponent(tbxNumQuestoesDisc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNumQuestoesFaceisDisc)
                    .addComponent(tbxNumQuestoesFaceisDisc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNumQuestoesMediasDisc)
                    .addComponent(tbxNumQuestoesMediasDisc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNumQuestoesDificiesDisc)
                    .addComponent(tbxNumQuestoesDificiesDisc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbQuestoesMultEsc)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNumQuestoesMultEsc)
                    .addComponent(tbxNumQuestoesMultEsc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNumQuestoesFaceisMultEsc)
                    .addComponent(tbxNumQuestoesFaceisMultEsc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNumQuestoesMediasMultEsc)
                    .addComponent(tbxNumQuestoesMediasMultEsc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbNumQuestoesDificiesMultEsc)
                    .addComponent(tbxNumQuestoesDificiesMultEsc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lbTopicos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbComentario, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12)
                .addComponent(btnGerarProva)
                .addContainerGap(50, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tbxNumQuestoesFaceisDiscFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbxNumQuestoesFaceisDiscFocusLost
            numTotalQuestaoDisc();
    }//GEN-LAST:event_tbxNumQuestoesFaceisDiscFocusLost

    private void tbxNumQuestoesMediasDiscFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbxNumQuestoesMediasDiscFocusLost
            numTotalQuestaoDisc();
    }//GEN-LAST:event_tbxNumQuestoesMediasDiscFocusLost

    private void tbxNumQuestoesDificiesDiscFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbxNumQuestoesDificiesDiscFocusLost
            numTotalQuestaoDisc();
    }//GEN-LAST:event_tbxNumQuestoesDificiesDiscFocusLost

    private void tbxNumQuestoesFaceisMultEscFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbxNumQuestoesFaceisMultEscFocusLost
            numTotalQuestaoMultEsc();
    }//GEN-LAST:event_tbxNumQuestoesFaceisMultEscFocusLost

    private void tbxNumQuestoesMediasMultEscFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbxNumQuestoesMediasMultEscFocusLost
            numTotalQuestaoMultEsc();
    }//GEN-LAST:event_tbxNumQuestoesMediasMultEscFocusLost

    private void tbxNumQuestoesDificiesMultEscFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tbxNumQuestoesDificiesMultEscFocusLost
            numTotalQuestaoMultEsc();
    }//GEN-LAST:event_tbxNumQuestoesDificiesMultEscFocusLost

    private void btnGerarProvaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGerarProvaActionPerformed
        
        try
        {
            Prova p = new Prova();

            int numQuestoesFaceisDisc = 0;
            int numQuestoesMediasDisc = 0;
            int numQuestoesDificiesDisc = 0;
            int numQuestoesFaceisMultEsc = 0;
            int numQuestoesMediasMultEsc = 0;
            int numQuestoesDificiesMultEsc = 0;

            if (!tbxNumQuestoesFaceisDisc.getText().isEmpty())
                numQuestoesFaceisDisc = Integer.parseInt(tbxNumQuestoesFaceisDisc.getText());
            if (!tbxNumQuestoesMediasDisc.getText().isEmpty())
                numQuestoesMediasDisc = Integer.parseInt(tbxNumQuestoesMediasDisc.getText());
            if (!(tbxNumQuestoesDificiesDisc.getText().isEmpty()))
                numQuestoesDificiesDisc = Integer.parseInt(tbxNumQuestoesDificiesDisc.getText());
            if (!(tbxNumQuestoesFaceisMultEsc.getText().isEmpty()))
                numQuestoesFaceisMultEsc = Integer.parseInt(tbxNumQuestoesFaceisMultEsc.getText());
            if (!tbxNumQuestoesMediasMultEsc.getText().isEmpty())
                numQuestoesMediasMultEsc = Integer.parseInt(tbxNumQuestoesMediasMultEsc.getText());
            if (!tbxNumQuestoesDificiesMultEsc.getText().isEmpty())
                numQuestoesDificiesMultEsc = Integer.parseInt(tbxNumQuestoesDificiesMultEsc.getText());

            Object[] selecionados = lbxTopicos.getSelectedValues();
            List<Topico> topicosProva = new ArrayList<Topico>();

            for (Topico t : topicos)
            {
                String nomeTopico = t.getTopico();
                for (int pos = 0; pos < selecionados.length; pos++) 
                    if (nomeTopico.equals(selecionados[pos].toString())) 
                        topicosProva.add(t);
            }

            if (selecionados.length == 0)
                MediaController.showErrorMessage("Pelo menos um tópico deve ser selecionado!",  "Erro!");
            else
            {
                p.gerarProva(numQuestoesFaceisDisc, numQuestoesMediasDisc, numQuestoesDificiesDisc, numQuestoesFaceisMultEsc, numQuestoesMediasMultEsc, numQuestoesDificiesMultEsc, topicosProva);
                this.dispose();
            }
        }
        catch (Exception ex)
        {
            MediaController.showErrorMessage("Erro nao identificado",  "Erro!");
        }
    }//GEN-LAST:event_btnGerarProvaActionPerformed

    private void populaListaTopicos() {
        try
        {
            topicos = topicoDAO.getTopicos();
            this.lbxTopicos.setListData(topicoDAO.getTopicos().toArray());
        } 
        catch (TopicoDAOException Topex)
        {
            MediaController.showErrorMessage("Não foi possível listar os Topicos.",  "Erro!");
        }
    }

    private void lbxTopicosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbxTopicosMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_lbxTopicosMouseClicked

    private void tbxNumQuestoesFaceisDiscKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxNumQuestoesFaceisDiscKeyTyped
        if (!Character.isDigit(evt.getKeyChar()))
               evt.setKeyChar('\u0000');
    }//GEN-LAST:event_tbxNumQuestoesFaceisDiscKeyTyped

    private void tbxNumQuestoesMediasDiscKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxNumQuestoesMediasDiscKeyTyped
        if (!Character.isDigit(evt.getKeyChar()))
               evt.setKeyChar('\u0000');
    }//GEN-LAST:event_tbxNumQuestoesMediasDiscKeyTyped

    private void tbxNumQuestoesDificiesDiscKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxNumQuestoesDificiesDiscKeyTyped
       if (!Character.isDigit(evt.getKeyChar()))
               evt.setKeyChar('\u0000');
    }//GEN-LAST:event_tbxNumQuestoesDificiesDiscKeyTyped

    private void tbxNumQuestoesFaceisMultEscKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxNumQuestoesFaceisMultEscKeyTyped
        if (!Character.isDigit(evt.getKeyChar()))
               evt.setKeyChar('\u0000');
    }//GEN-LAST:event_tbxNumQuestoesFaceisMultEscKeyTyped

    private void tbxNumQuestoesMediasMultEscKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxNumQuestoesMediasMultEscKeyTyped
       if (!Character.isDigit(evt.getKeyChar()))
               evt.setKeyChar('\u0000');
    }//GEN-LAST:event_tbxNumQuestoesMediasMultEscKeyTyped

    private void tbxNumQuestoesDificiesMultEscKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxNumQuestoesDificiesMultEscKeyTyped
        if (!Character.isDigit(evt.getKeyChar()))
               evt.setKeyChar('\u0000');
    }//GEN-LAST:event_tbxNumQuestoesDificiesMultEscKeyTyped

    private void numTotalQuestaoDisc()
    {
        int numtotal = 0;
        int numFaceis = 0;
        int numMedias = 0;
        int numDificies = 0;

        if (!tbxNumQuestoesFaceisDisc.getText().isEmpty()) 
            numFaceis = (Integer.parseInt(tbxNumQuestoesFaceisDisc.getText()));

        if (!tbxNumQuestoesMediasDisc.getText().isEmpty()) 
            numMedias = (Integer.parseInt(tbxNumQuestoesMediasDisc.getText()));
        
        if (!tbxNumQuestoesDificiesDisc.getText().isEmpty()) 
            numDificies = (Integer.parseInt(tbxNumQuestoesDificiesDisc.getText()));

        numtotal = numFaceis + numMedias + numDificies;

        tbxNumQuestoesDisc.setText(String.valueOf(numtotal));
    }

    private void numTotalQuestaoMultEsc()
    {
        int numtotal = 0;
        int numFaceis = 0;
        int numMedias = 0;
        int numDificies = 0;

        if (!tbxNumQuestoesFaceisMultEsc.getText().isEmpty()) 
            numFaceis = (Integer.parseInt(tbxNumQuestoesFaceisMultEsc.getText()));
        
        if (!tbxNumQuestoesMediasMultEsc.getText().isEmpty()) 
            numMedias = (Integer.parseInt(tbxNumQuestoesMediasMultEsc.getText()));
        
        if (!tbxNumQuestoesDificiesMultEsc.getText().isEmpty()) 
            numDificies = (Integer.parseInt(tbxNumQuestoesDificiesMultEsc.getText()));

        numtotal = numFaceis + numMedias + numDificies;
        tbxNumQuestoesMultEsc.setText(String.valueOf(numtotal));
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnGerarProva;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JLabel lbComentario;
    private javax.swing.JLabel lbNumQuestoesDificiesDisc;
    private javax.swing.JLabel lbNumQuestoesDificiesMultEsc;
    private javax.swing.JLabel lbNumQuestoesDisc;
    private javax.swing.JLabel lbNumQuestoesFaceisDisc;
    private javax.swing.JLabel lbNumQuestoesFaceisMultEsc;
    private javax.swing.JLabel lbNumQuestoesMediasDisc;
    private javax.swing.JLabel lbNumQuestoesMediasMultEsc;
    private javax.swing.JLabel lbNumQuestoesMultEsc;
    private javax.swing.JLabel lbQuestoesDisc;
    private javax.swing.JLabel lbQuestoesMultEsc;
    private javax.swing.JLabel lbTopicos;
    private javax.swing.JList lbxTopicos;
    private javax.swing.JTextField tbxNumQuestoesDificiesDisc;
    private javax.swing.JTextField tbxNumQuestoesDificiesMultEsc;
    private javax.swing.JTextField tbxNumQuestoesDisc;
    private javax.swing.JTextField tbxNumQuestoesFaceisDisc;
    private javax.swing.JTextField tbxNumQuestoesFaceisMultEsc;
    private javax.swing.JTextField tbxNumQuestoesMediasDisc;
    private javax.swing.JTextField tbxNumQuestoesMediasMultEsc;
    private javax.swing.JTextField tbxNumQuestoesMultEsc;
    // End of variables declaration//GEN-END:variables
}
